#include<bits/stdc++.h>
#define N 150
using namespace std;

string S = "                                                                                                                                        ", s;
int n, cnt, ans, p[N];
void manacher() {
	cnt = 0;
	s[++cnt] = '~'; s[++cnt] = '#';
    for(int i = 1; i <= n; i++) s[++cnt] = S[i], s[++cnt] = '#';
    s[++cnt] = '!';
    memset(p, 0, sizeof(p));
    int mr = 0, mid = 0;
    for(int i = 2; i <= cnt - 1; i++) {
    	if(i <= mr) p[i] = min(p[2 * mid - i], mr - i + 1);
    	else p[i] = 1;
    	while(s[i - p[i]] == s[i + p[i]]) p[i]++;
    	if(i + p[i] - 1 > mr) mr = i + p[i] - 1, mid = i;
    	ans = max(ans, p[i]);
	}
//	for(int i = 3; i <= cnt - 2; i++) cout << p[i] - 1 << " ";
}
int Hou[N], M[N];
struct node {
	string z;
	int id;
}g[N];
bool cmp(node x, node y) {
	return x.z < y.z;
}
bool flag;
void dfs(int k) {
	if(flag)return;
	if(k > n) {
		
		manacher();
		for(int i = 3; i <= cnt - 2; i++)
			if(p[i] - 1 != M[i - 2]) return;
			
		//for(int i = 1; i <= n; i++) cout << S[i];
		//cout << endl;
		for(int i = 1; i <= n; i++) {
			g[i].id = i;
			g[i].z = S.substr(i, n - i + 1);
		}
		sort(g + 1, g + n + 1, cmp);
		for(int i = 1; i <= n; i++)
			if(g[i].id != Hou[i] + 1) return;
		for(int i = 1; i <= n; i++) cout << S[i];
		cout << endl;
		flag = 1;
		return;
		
	}
	for(int i = 0; i < 8; i++) {
		S[k] = 'a' + i;
		dfs(k + 1);
	}
}
int T;

void Sol() {
	flag = 0;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> Hou[i];
	for(int i = 1; i <= 2 * n - 1; i++) cin >> M[i];
	dfs(1);
	if(!flag) cout << -1 << endl;
}
signed main() {
	freopen("string.in", "r", stdin);
	freopen("string.out", "w", stdout);
	cin >> T;
	while(T--) Sol();
	
//	cout << (int)pow(10, 8);
    
	return 0;
}



/*
1
8
4 6 5 3 2 0 1 7
1 0 3 0 1 0 1 0 1 0 1 0 1 0 1
*/



